DELIM          [\t ]
IDENTIFIER     [[:alpha:]][[:alnum:]]*
NAT_LITERAL    [[:digit:]]+
EXPONENT       [Ee][+-][[:digit:]]+
REAL_LITERAL   [[:digit:]]+"."[[:digit:]]+{EXPONENT}?
SINGLE_CHAR    [[:alnum:]]
CHAR_LITERAL   \'SINGLE_CHAR?\'
STRING_LITERAL \"SINGLE_CHAR*\" 
LOGIC_LITERAL  (true)|(false)

ALLOC          alloc
CODE           code
MAPS           maps
INTO           into
RETURN         return

ITERATE        iterate
LOOP           loop
IF             if
PRINT          print
SCAN           scan

LET            let
SWAP           swap
TEST           test
RETEST         retest
INSTEAD        instead

IN             in
AND            "/\\"
OR             "\\/"

INT            int
NAT            nat
REAL           real
LOGIC          logic
STRING         string
CHAR           char
SET            set
VECTOR         vector
ARRAY          array

%%

[\n]             { numLinha++; numCol = 0; ultimaLinha = ""; }
{DELIM}          { numCol++; ultimaLinha += yytext; }

{ALLOC}          { traceToken(yytext);                return ALLOC;          }
{CODE}           { traceToken(yytext);                return CODE;           }
{MAPS}           { traceToken(yytext);                return MAPS;           }
{INTO}           { traceToken(yytext);                return INTO;           }
{RETURN}         { traceToken(yytext);                return RETURN;         }

{ITERATE}        { traceToken(yytext);                return ITERATE;        }
".."             { traceToken(yytext);                return RANGE;          }
{LOOP}           { traceToken(yytext);                return LOOP;           }
{IF}             { traceToken(yytext);                return IF;             }
{PRINT}          { traceToken(yytext);                return PRINT;          }
{SCAN}           { traceToken(yytext);                return SCAN;           }

{LET}            { traceToken(yytext);                return LET;            }
{SWAP}           { traceToken(yytext);                return SWAP;           }
{TEST}           { traceToken(yytext);                return TEST;           }
{RETEST}         { traceToken(yytext);                return RETEST;         }
{INSTEAD}        { traceToken(yytext);                return INSTEAD;        }

{IN}             { traceToken(yytext);                return IN;             }
{AND}            { traceToken(yytext);                return AND;            }
{OR}             { traceToken(yytext);                return OR;             }

{INT}            { traceToken(yytext, Int::type());   return INT;            }
{NAT}            { traceToken(yytext, Nat::type());   return NAT;            }
{REAL}           { traceToken(yytext, Real::type());  return REAL;           }
{CHAR}           { traceToken(yytext, Char::type());  return CHAR;           }
{STRING}         { traceToken(yytext);                return STRING;         }
{LOGIC}          { traceToken(yytext, Logic::type()); return LOGIC;          }
{VECTOR}         { traceToken(yytext);                return VECTOR;         }
{ARRAY}          { traceToken(yytext);                return ARRAY;          }
{SET}            { traceToken(yytext);                return SET;            }


">="             { traceToken(yytext);                return GEQ;            }
"<="             { traceToken(yytext);                return LEQ;            }
"<>"             { traceToken(yytext);                return SWAP_OP;        }
"!="             { traceToken(yytext);                return DIF;            }
"=="             { traceToken(yytext);                return EQ;             }

{NAT_LITERAL}    { traceToken(yytext, Nat::type());   return NAT_LITERAL;    }
{REAL_LITERAL}   { traceToken(yytext, Real::type());  return REAL_LITERAL;   }
{CHAR_LITERAL}   { traceToken(yytext, Char::type());  return CHAR_LITERAL;   }
{STRING_LITERAL} { traceToken(yytext);                return STRING_LITERAL; }
true             { traceToken("1",    Logic::type()); return LOGIC_LITERAL;  }
false            { traceToken("0",    Logic::type()); return LOGIC_LITERAL;  }
{LOGIC_LITERAL}  { traceToken(yytext, Logic::type()); return LOGIC_LITERAL;  }

{IDENTIFIER}     { traceToken(yytext);                return IDENTIFIER;     }

.                { traceToken(yytext);                return *yytext;        }
